import request from '@/utils/request'

const userApi = {
  Login: '/user/login',
  Logout: '/user/logout',
  SendEamil: '/mail/code',
  // get my info
  UserInfo: '/user/info'
}

// 主要就是得到 token
export function login (parameter) {
  return request({
    url: userApi.Login,
    method: 'post',
    data: {
      username: parameter.username,
      password: parameter.password,
      loginType: parameter.loginType || 0
    }
  })
}

export function getSmsCaptcha (parameter) {
  return request({
    url: userApi.SendEamil,
    method: 'get',
    params: {
      to: parameter.email
    }
  })
}

export function getInfo () {
  return request({
    url: userApi.UserInfo,
    method: 'get'
  })
}

export function logout (parameter) {
  return request({
    url: userApi.Logout,
    method: 'get',
    params: {
      id: parameter.id
    }
  })
}
